<!--报价单列表-->
<template>
  <div class="GenerateQuotationList"
       v-loading="loading"
       element-loading-customClass="ne-loading"
       element-loading-background="rgba(255, 255, 255, 0.6)"
  >
    <DicTable
        height="100%"
        stripe
        highlight-current-row
        highlight-hover-row
        max-height="600"
        ref="GBLtable"
        border
        header-row-class-name="header-row-class"
        row-class-name="ne-row-class"
        :columnData="GBLtbs.tableColumns"
        :tableData="GBLtbs.tableData"
        :loading="GBLtbs.tableLoading"
        :currentPage="GBLtbs.tablePage.page"
        :pageSize="GBLtbs.tablePage.pageSize"
        :totalResult="GBLtbs.tablePage.totalResult"
        :pager="true"
        @cell-click="cellClickEvent"
        @on-page-change="handlePageChange"
    >
      <template #viewRent="{ row }">
        <a class="link" @click="viewRentFun(row)">查看</a>
      </template>
    </DicTable>
    <el-dialog class="" append-to-body :close-on-click-modal='false' width="98%" top='3vh' title="报价单详情" v-if="dialogVisible" :visible.sync="dialogVisible">
      <component
          :show.sync="dialogVisible"
          :is="content"
          :ODKInfo="ODKInfo"
          :CTOInfo="CTOInfo"
      ></component>
    </el-dialog>
  </div>
</template>
<script>
import DicTable from "@/components/public/DicTable";
import GenerateQuotations from "@/components/custorder/pengding/GenerateQuotations";
import GenerateAQuotations from "@/components/custorder/pengding/GenerateAQuotations";
import CustOrderService from "@/api/order/CustOrderService";
import { mapState } from "vuex";
export default {
  name: "GenerateQuotationList",
  data() {
    return {
      loading: false,
      dialogVisible: false,
      content: '',
      GBLtbs:{
        tableColumns: [],
        tableData:  [],
        tableLoading: false,
        tablePage: {
          currentPage: 1,
          pageSize: 10,
          totalResult: 0,
        },
      }
    }
  },
  props: {
    ODKInfo: {
      type: Object
    },
    CTOInfo: {
      type: Object
    }
  },
  computed:{
    ...mapState('user',['user'])
  },
  mounted() {
    this.getDetail();
  },
  created() {

  },
  components: {DicTable,GenerateQuotations,GenerateAQuotations},
  methods: {
    viewRentFun(row){
      this.content = 'GenerateAQuotations';
      this.dialogVisible = true;
    },
    async getDetail() {
      this.loading = true;
      let{custOrderId,custSoNumber,offerType,custId} = this.CTOInfo,
          pageInfo={
            pageIndex: ~~this.GBLtbs.tablePage.pageIndex+'',
            pageSize: ~~this.GBLtbs.tablePage.pageSize+''
          },
          params = {custOrderId,custSoNumber,custId,prodType:offerType,pageInfo:pageInfo};
      const result = await CustOrderService.qryGenerateQuotationList(params);
      this.loading = false;
      if(result.meta.resultCode == '0'){
        if(result.meta.busiAFlag=='1'){
          // A端
          this.content = 'GenerateQuotations';
          this.GBLtbs.tableColumns = [
            { field: "custOrderId", title: "订单id"},
            { slotName: "viewRent", title: "查看月租费"},
            { field: "custSoNumber", title: "流水号"},
            { field: "createDate", title: "创建日期"},
            { field: "createUserName", title: "创建人"},
            { field: "audFalg", title: "状态"},
            { field: "audDate", title: "审核日期"},
            { field: "amount", title: "一次性报价金额"}
          ];
        }else{
          this.content = 'GenerateQuotations';
          this.GBLtbs.tableColumns = [
            { field: "custOrderId", title: "订单id"},
            { field: "custSoNumber", title: "流水号"},
            { field: "createDate", title: "创建日期"},
            { field: "createUserName", title: "创建人"},
            { field: "audFalg", title: "状态"},
            { field: "audDate", title: "审核日期"},
            { field: "amount", title: "一次性报价金额"}
          ];
        }
        if(result.meta.acctItemQuotations){
          this.GBLtbs.tableData = result.meta.acctItemQuotations;
        }
      }else{
        this.$message({
          showClose: true,
          message: result.meta.resultMsg,
          type: "error",
        });
      }
      
    },
    // 行点击事件
    cellClickEvent () {
      
      this.dialogVisible = true;
    },
    handlePageChange({ currentPage, pageSize }) {
      this.GBLtbs.tablePage.currentPage = currentPage;
      this.GBLtbs.tablePage.pageSize = pageSize;

    },
  }
}
</script>

<style lang="scss" scoped>
  .link{
    color: blue;
    &:hover{
      text-decoration: underline;
      color: blue;
    }
  }
</style>
